package co.sanduche.util;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.widget.Toast;

public class DialogUtil {

	public static void alert(android.app.Fragment context, final String message) {
		new android.app.DialogFragment() {
			@Override
			public Dialog onCreateDialog(Bundle savedInstanceState) {
				// Use the Builder class for convenient
				// dialog construction
				AlertDialog.Builder builder = new AlertDialog.Builder(
						getActivity());

				builder.setMessage(message).setPositiveButton("Aceptar",
						new DialogInterface.OnClickListener() {
							public void onClick(DialogInterface dialog, int id) {

							}
						});

				// Create the AlertDialog object and return
				// it
				return builder.create();
			}
		}.show(context.getFragmentManager(), "alert");
	}

	public static void alert(android.support.v4.app.Fragment context,
			final String message) {
		new android.support.v4.app.DialogFragment() {
			@Override
			public Dialog onCreateDialog(Bundle savedInstanceState) {
				// Use the Builder class for convenient
				// dialog construction
				AlertDialog.Builder builder = new AlertDialog.Builder(
						getActivity());

				builder.setMessage(message).setPositiveButton("Aceptar",
						new DialogInterface.OnClickListener() {
							public void onClick(DialogInterface dialog, int id) {

							}
						});

				// Create the AlertDialog object and return
				// it
				return builder.create();
			}
		}.show(context.getFragmentManager(), "alert");
	}

	public static void alert(android.app.Activity context, final String message) {
		new android.app.DialogFragment() {
			@Override
			public Dialog onCreateDialog(Bundle savedInstanceState) {
				// Use the Builder class for convenient
				// dialog construction
				AlertDialog.Builder builder = new AlertDialog.Builder(
						getActivity());

				builder.setMessage(message).setPositiveButton("Aceptar",
						new DialogInterface.OnClickListener() {
							public void onClick(DialogInterface dialog, int id) {

							}
						});

				// Create the AlertDialog object and return
				// it
				return builder.create();
			}
		}.show(context.getFragmentManager(), "alert");
	}

	public static void message(final Activity context, final String message) {
		context.runOnUiThread(new Runnable() {

			@Override
			public void run() {
				Toast.makeText(context, message, Toast.LENGTH_LONG).show();
			}
		});

	}

	public static void shortMessage(final Activity context, final String message) {
		context.runOnUiThread(new Runnable() {

			@Override
			public void run() {
				Toast.makeText(context, message, Toast.LENGTH_SHORT).show();
			}
		});

	}

}
